package com.qf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.dao.ExamDao;
import com.qf.entity.TbExam;
import com.qf.service.ExamService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExamServiceImpl extends ServiceImpl<ExamDao, TbExam> implements ExamService {

    @Autowired(required = false)
    ResultMsg resultMsg;

    @Override
    public ResultMsg findAllExam(int page, int limit) {
        Page page1 = new Page<TbExam>(page,limit);
        Page page2 = this.page(page1);
        return resultMsg.success(page2);
    }

    @Override
    public ResultMsg addOrUpdataExam(TbExam tbExam) {
        boolean b = this.saveOrUpdate(tbExam);
        if (b)
            return resultMsg.success();
        return resultMsg.faild(300,"提交失败,请重试");
    }

    @Override
    public ResultMsg deleteExam(Integer examId) {
        boolean b = this.removeById(examId);
        if (b)
            return resultMsg.success();
        return resultMsg.faild(300,"删除失败");
    }
}
